package org.gwtEss.link;

import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.Label;

public class LabelLink extends Label{
	boolean enabled = true; 
	public LabelLink() {
		super();
		init();
	}

	public LabelLink(Element element) {
		super(element);
		init();
	}

	public LabelLink(String text, boolean wordWrap) {
		super(text, wordWrap);
		init();
	}

	public LabelLink(String text) {
		super(text);
		init();
	}

	public LabelLink(Element element, ClickHandler clickHandler) {
		super(element);
		init();
		addClickHandler(clickHandler);
	}

	public LabelLink(String text, boolean wordWrap, ClickHandler clickHandler) {
		super(text, wordWrap);
		init();
		addClickHandler(clickHandler);
	}

	public LabelLink(String text, ClickHandler clickHandler) {
		super(text);
		init();
		addClickHandler(clickHandler);
	}

	private void init(){
		addStyleName("LabelLink");
	}
	@Override
	public void onBrowserEvent(Event event) {
		if (enabled)
			super.onBrowserEvent(event);
	}
	public void setEnabled(boolean enabled) {
		if (this.enabled == enabled)
			return; 
		if (enabled){
			removeStyleName("LabelLink-disabled");	
			addStyleName("LabelLink");
		}else{
			removeStyleName("LabelLink");
			addStyleName("LabelLink-disabled");	
		}
		this.enabled = enabled;
		
	}
}
